<?php
	//echo $this->userType;
	$para=$_GET;


// 用户限制
if($para['username'] && $para['username']!='用户名'){
	$para['username']=wjStrFilter($para['username']);
	if(!ctype_alnum($para['username'])) throw new Exception('用户名包含非法字符,请重新输入');
	$whereStr .= " and u.username like '%{$para['username']}%' and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} ) ";
}

// 帐变类型限制
$para['liqType']=intval($para['liqType']);
if($para['liqType']){
	$liqTypeWhere="and l.liqType={$para['liqType']}";
	if($_REQUEST['liqType']==2) $liqTypeWhere=' and liqType=2 or liqType=3';
}

// 彩种限制
$_REQUEST['type']=intval($_REQUEST['type']);
if($_REQUEST['type']){
	$typeWhere="and l.type={$_REQUEST['type']}";
}

// 时间限制
if($_REQUEST['fromTime'] && $_REQUEST['toTime']){
	$fromTime=strtotime($_REQUEST['fromTime']);
	$toTime=strtotime($_REQUEST['toTime'])+24*3600;
	$timeWhere="and l.actionTime between $fromTime and $toTime";
}elseif($_REQUEST['fromTime']){
	$fromTime=strtotime($_REQUEST['fromTime']);
	$timeWhere="and l.actionTime>=$fromTime";
}elseif($_REQUEST['toTime']){
	$toTime=strtotime($_REQUEST['toTime'])+24*3600;
	$timeWhere="and l.actionTime<$fromTime";
}else{
	$timeWhere=' and l.actionTime>'.strtotime('00:00');
}
		switch($para['utype']){
			case 1:
				//我自己
				$whereStr .= " and l.uid={$this->user['uid']} ";
				break;
			case 2:
				//直属下线
				if($this->user['type']==1){
				$whereStr.=" and u.parentId={$this->user['uid']} and u.type=0 ";
				}elseif($this->user['type']==2){
				$whereStr.=" and u.zparentId={$this->user['uid']} and u.type=1 or (u.zparentId={$this->user['uid']} and u.parentId='' and u.type=0) ";
				}elseif($this->user['type']==3){
				$whereStr.=" and u.gudongId={$this->user['uid']} and u.type=2 or (u.gudongId={$this->user['uid']} and u.zparentId='' and u.parentId='' and u.type!=3) ";
				}
				break;
			case 3:
				// 所有下级
				$whereStr .= "  and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} or u.uid={$this->user['uid']} ) and u.uid !={$this->user['uid']} ";
				break;
			default:
				// 所有人
				$whereStr .= "  and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} or u.uid={$this->user['uid']} ) ";
			break;
		}

$sql="select l.*, u.username from {$this->prename}coin_log l,{$this->prename}members u where l.uid=u.uid $timeWhere $liqTypeWhere $typeWhere $userWhere $whereStr and l.liqType not in(4,11,104) order by l.id desc";


$data=$this->getPage($sql, $this->page, $this->pageSize);
$sql="select playedId, actionNo,Groupname from {$this->prename}bets where id=?";



	$params=http_build_query($para, '', '&');
?>
<div>
<table width="100%" class='table_b'>
	<thead>
		<tr class="table_b_th">
			<th>用户名</th>
			<th>帐变类型</th>
			<th>单号</th>
			<th>游戏</th>
			<th>玩法</th>
			<th>投注号码</th>
			<th>期号</th>
			<th>资金</th>
			<th>余额</th>
			<th>时间</th>
		</tr>
	</thead>
	<tbody class="table_b_tr">
	<?php if($data['data']){ 
	foreach($data['data'] as $var){ ?>
		<tr>
			<td><?=$var['username']?></td>
			<td><?=$var['info']?></td>
			<?php if($var['extfield0'] && in_array($var['liqType'], array(2,3,4,5,6,7,10,11,100,101,102,103,104,105,108))){ ?>
				<td><a target="modal" button="关闭:defaultCloseModal" width="510" title="投注信息" href="/admin778899.php/business/betInfo/<?=$var['extfield0']?>"><?=$this->ifs($var['extfield0'], '--')?></a>
				</td>
				<td><?=$this->iff($var['type'], $this->types[$var['type']]['title'], '--')?></td>
				<td><?=$this->ifs($bet['Groupname'],'--')?></td>
				<td><?=$this->iff($bet['playedId'], $this->playeds[$bet['playedId']]['name'], '--')?></td>
				<td><?=$this->ifs($bet['actionNo'], '--')?></td>
			<?php }elseif(in_array($var['liqType'], array(1,9,52))){?>
				<td><a href="/admin778899.php/business/rechargeInfo/<?=$var['extfield0']?>" width="500" title="充值信息" button="关闭:defaultCloseModal" target="modal"><?=$var['extfield1']?></a></td>
				<td>--</td>
				<td>--</td>
				<td>--</td>
				<td>--</td>
			<?php }elseif(in_array($var['liqType'], array(8,106,107))){?>
				<td><a href="/admin778899.php/business/cashInfo/<?=$var['extfield0']?>" width="500" title="提现信息" button="关闭:defaultCloseModal" target="modal"><?=$var['extfield0']?></a></td>
				<td>--</td>
				<td>--</td>
				<td>--</td>
				<td>--</td>

			<?php }else{ ?>
				<td>--</td>
				<td>--</td>
				<td>--</td>
				<td>--</td>
				<td>--</td>
			<?php } ?>

			<td><?=$var['coin']?></td>
			<td><?=$var['userCoin']?></td>
			<td><?=date('m-d H:i', $var['actionTime'])?></td>
		</tr>
	<?php } }else{ ?>
    <tr><td colspan="12">暂无投注信息</td></tr>
    <?php } ?>
	</tbody>
</table>
<?php 
	$this->display('inc_page.php',0,$data['total'],$this->pageSize, "/index.php/{$this->controller}/{$this->action}-{page}/?$params");
?>
</div>